package controller

import (
	"project1/dbmodel"
	"project1/service"

	"github.com/kataras/iris/v12"
)

type CommController struct {
	BaseController
	Service *service.CommService
}

// 构造函数
func NewCommController() *CommController {
	return &CommController{
		BaseController: *NewBaseController(),
	}
}

// post写入mysql用户表参数
func (c *CommController) PostUser(ctx iris.Context) {
	bodyData := dbmodel.User{}
	err := c.ValidateParams.CheckStructParams(ctx.FormValues(), map[string][]string{
		"int": {"cardId", "Status"},
	}, &bodyData)
	if err != nil {
		c.ApiReturn(ctx, "", err)
		return
	}
	data, err := c.Service.PostUser(&bodyData)
	c.ApiReturn(ctx, data, err)
}
